#include "msg.h"
#include "Stack.h"
using namespace msg;
using namespace std;

void push_size()
{
	Stack hop;
	Step("In this section, we will test push(int) and int size() member functions",0);
	Step("Be some empty stack");
	
	//testing push
	Step("With push(int) add values 1, 2, 3 in this order to it.");
	hop.push(1); hop.push(2); hop.push(3);
	Pause(false);
	Step("Using print() we should see 3, 2, 1 in this order from TOP to BOTTOM.");
	hop.print();
	
	//size
	Pause();
	Step("And the stack's size returned by size() is:");
	cout << hop.size() << endl;
}

void pop_clear()
{
	Stack hop;
	int tmp;
	
	//clear with nothing
	Step("In this section, we will test int pop() and void clear() member functions",0);
	Step("Be some empty stack; let's apply clear() on it to bulletproof.\nnote: we enable debug for this section");
	hop.enableDebug();
	Step("With debug enabled this should work ok and say something.");
	hop.clear();
	Pause();
	
	//clear with something
	Step("Now let us try clear() with a non-empty stack.");
	hop.add(18); hop.add(-2); hop.add(39);
	Pause(false);
	Step("Before clear() the stack is:");
	hop.print();
	Pause(false);
	Step("After clear() the stack is:");
	hop.clear();
	hop.print();
	Pause();
	
	//pop
	Step("Now let's push elements 3, 4, 5 to our previously empty list.");
	hop.push(3); hop.push(4); hop.push(5);
	hop.print();
	Pause(false);
	Step("And let's pop the numbers 4 times (one time too many).");
	for(int a=0;a<4;a++)
	{
		tmp = hop.pop();
		cout << "got "<<tmp<<" from the top"<<endl;
	}
	Pause(false);
	Step("The stack is now:");
	hop.print();
}

int main()
{
	MenuItem m1(push_size,"void push(), int size()");
	MenuItem m2(pop_clear,"int pop(), void clear()");
	Menu M("testing the Stack class");
	
	M.add(m1);
	M.add(m2);
	M.run();
	
	return 0;
}
